﻿package yii.collections{

	import yii.base.*
	import phpas3.*;

	public class CMap extends CComponent{








	/**
	 * Merges two arrays into one recursively+
	 * If each array has an element with the same string key value, the latter
	 * will overwrite the former (different from array_merge_recursive)+
	 * Recursive merging will be conducted if both arrays have an element of array
	 * type and are having the same key+
	 * For integer-keyed elements, the elements from the latter array will
	 * be appended to the former array+
	 * @param array $a array to be merged to
	 * @param array $b array to be merged from
	 * @return array the merged array (the original arrays are not changed+)
	 * @see mergeWith
	 */
	public static function mergeArray( $a:Object, $b:Object ):Object{
		for( var $k in $b ){
			var $v = $b[$k];
			if( is_int($k) ){
				isset($a[$k]) ? $a.push($v) : $a[$k]=$v;
			} else if( is_array($v) && isset($a[$k]) && is_array($a[$k]) ){
				$a[$k] = mergeArray( $a[$k], $v );
			} else {
				$a[$k] = $v;
			}
		}
		return $a;
	}






















	}


}